package com.jereh.topnews.api;

import com.jereh.topnews.entity.Channel;

/**
 * Created by Administrator on 2016/11/18.
 */
public class NewsApi {
    //接口地址
    public static final String HTTP_URL="http://apis.baidu.com/showapi_open_bus/channel_news/search_news";

    //频道信息接口地址
    public static final String CHANNEL_URL="http://apis.baidu.com/showapi_open_bus/channel_news/channel_news";

    //apikey
    public static final String apikey="a52d8b4dfce6acab1649ad427584483d";

    /**
     *  返回接口完整地址
     * @param channel
     * @param page
     * @return
     */
    public static String getNewsListApi(Channel channel,int page){
        String api=HTTP_URL;
        //接口地址跟传参进行拼接
        api=api+"?channelId="+channel.getChannelId()+"&page="+page+"&needContent=1&needHtml=1";
        return api;
    }

    /**
     * 获取新闻详细内容的接口地址
     * @param channel
     * @param title
     * @return
     */
//    public static String getNewsContentApi(Channel channel,String title){
//        String api=HTTP_URL;
//        //接口地址跟传参进行拼接
//        api=api+"?channelId="+channel.getChannelId()+"&channelName="+ StringUtil.urlencode(channel.getName())+"&needContent=1&needHtml=1"
//                +"&title="+StringUtil.urlencode(title.substring(0,title.length()-2));
//        return api;
//    }

}